﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace Bookkeeping.Mvc
{
    public class MvcApplication : System.Web.HttpApplication
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                "ShortBudgetWithDetails",
                "{year}/{month}/details/{selectedId}",
                new { controller = "Budget", action = "List" },
                new { year = @"\d{4}", month = @"\d{1,2}", selectedId = @"\d+" }
            );

            routes.MapRoute(
                "ShortBudget",
                "{year}/{month}",
                new { controller = "Budget", action = "List" },
                new { year = @"\d{4}", month = @"\d{1,2}" }
            );

            routes.MapRoute(
                "Budget",
                "Budget/{year}/{month}/details/{selectedId}",
                new { controller = "Budget", action = "List" },
                new { year = @"\d{4}", month = @"\d{1,2}", selectedId = @"\d+" }
            );

            routes.MapRoute(
                "Add Budget Post",
                "BudgetPost/Add/{year}/{month}",
                new { controller = "BudgetPost", action = "Add" },
                new { year = @"\d{4}", month = @"\d{1,2}" }
            );


            routes.MapRoute(
                "Default",
                "{controller}/{action}/{id}",
                new { controller = "Budget", action = "List", id = "" }
            );

        }

        protected void Application_Start()
        {
            RegisterRoutes(RouteTable.Routes);
        }
    }
}